/** base64转File类型 */
export function base64ToFile(base64Data: string, filename: string, filetype: string) {
    try {
        //截取该内容之后的部分
        if (base64Data.includes('base64,')) {
            base64Data = base64Data.split('base64,')[1]
        }
        const byteCharacters = window.atob(base64Data)
        const byteArrays = []
        for (let _offset = 0; _offset < byteCharacters.length; _offset += 512) {
            const slice = byteCharacters.slice(_offset, _offset + 512)
            const byteNumbers = new Array(slice.length)
            for (let i = 0; i < slice.length; i++) {
                byteNumbers[i] = slice.charCodeAt(i)
            }
            const byteArray = new Uint8Array(byteNumbers)
            byteArrays.push(byteArray)
        }
        const file = new File(byteArrays, filename, { type: filetype })
        return file

    } catch (error) {
        console.error(error)
        return false
    }
}
